{template 'webheader'}
{template 'common/header'}
<style>
    .help-text{
        padding:5px 0;
        font-size:15px;
        color:red;
        display: block;
    }
</style>
<div class="panel panel-default">
    <div class="panel-heading">设置</div>
  <div class="panel-body">
      规则:<br>
      每月任意21天连续打卡都算合格<br>
      每月月初会统计出合格的用户<br>
      具体奖励由商家安排<br>
      
      <br><br>
      推荐激励方案1:<br>
      在文案中描述每月连续打卡满21天有礼品赠送<br>
      次月初，系统会统计出满足条件的用户,可以抽选部分用户,在文案中公布中奖结果(后续事情人工处理)
      
      <br>
      推荐激励方案2:<br>
      在文案中描述每月连续打卡满21天额外瓜分现金补贴<br>
      次月初，系统会统计出满足条件的用户,填写额外补贴金额，提交后会平分给所有满足条件的用户
      <br>
    <a  href='{php echo $this->createWebUrl("setlianxu")}' class="btn btn-warning">详细设置</a>
  </div>
</div>
<div class="panel panel-default">
    <div class="panel-body">
        <form  class="form-horizontal" role="form">
            <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">额外奖励</label>
                <div class="col-sm-6 col-md-8 col-lg-8 col-xs-12">
                    <input 
                        id="ewaimoney"
                        type="text" class="form-control" placeholder="请填写额外奖励总金额">
                    <span class="help-text">
                        每月可以通过这里为连续打卡的用户发放额外奖励<br>
                        每人得到金额=总金额/人数
                    </span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
                <div class="col-xs-12 col-sm-3 col-md-2 col-lg-2">
                    <a onclick="fafang()" class="btn btn-primary">发放</a>
                </div>
            </div>
        </form>
        
    </div>
</div>

<div class="panel panel-info">
    <div class="panel-heading">筛选</div>
    <div class="panel-body">
        <form action="./index.php?dd=1" method="get" class="form-horizontal" role="form">
            <div class="form-group">
                <input type="hidden" name="c" value="site">
                <input type="hidden" name="a" value="entry">
                <input type="hidden" name="do" value="lianxu">
                <input type="hidden" name="op" value="index">
                <input type="hidden" name="m" value="hai105_daka">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">时间</label>
                <div class="col-sm-6 col-md-8 col-lg-8 col-xs-12">
                    {php echo _tpl_form_field_date('date', $value = $_GPC['date'], $withtime = false);}
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
                <div class="col-xs-12 col-sm-3 col-md-2 col-lg-2">
                    <button type='submit' class="btn btn-primary">提交</button>
                </div>
            </div>
        </form>
    </div>
</div>


<div class="panel panel-default">
    <div class="panel-body table-responsive">
        <table class="table table-hover">
            <thead>
                <tr>
                    <th>#</th>
                    <th>UID</th>
                    <th>头像</th>
                    <th>昵称</th>
                    <th>openid</th>
                    <th>月份</th>
                    <th>连续天数</th>
                    <th>奖励金</th>
                </tr>
            </thead>
            <tbody>
                {loop $list $item}
                <tr>
                    <th scope="row">{$item['id']}</th>
                    <th scope="row">{$item['uid']}</th>
                    <td><img src="{$item['fansinfo']['headimgurl']}" width="60" height="60" /></td>
                    <td>{$item['fansinfo']['nickname']}</td>
                    <td>{$item['fansinfo']['openid']}</td>
                    <td>{$item['date']}</td>
                    <td>{$item['days']}</td>
                    <td>{$item['money']}</td>
                </tr>
                {/loop}
            </tbody>
        </table>
    </div>
    <div class="pull-right">{$pager}</div>
</div>
<script>
    function fafang () {
        var money = $('#ewaimoney').val();
        if(!money) {
            weui.alert('请填写额外奖励总金额');
            return false;
        }
        var confirm = weui.confirm('确定为连续打卡用户发放'+money+'元额外奖励？', function(){
            $.ajax({
                type: 'get',
                url: window.location.href+'&action=fafang&money='+money,
                dataType:'json'
            }).then(function(res){
                if(res.ret==0){
                    confirm.hide(function(){
                        weui.alert('发放成功');
                    })
                }else{
                    confirm.hide(function(){
                        weui.alert(res.message);
                    })
                }
            });
            return false;
        });
    }
</script>
{template 'common/footer'}